package com.yarin.android.Adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.yarin.android.TodayDate.ImageViewAcity;
import com.yarin.android.TodayDate.R;

public class ImageAdapter extends BaseAdapter {

	private Context mContext;
	private String PATH = "/sdcard/goods/pic";
	private List<Pic> list;

	public ImageAdapter(Context c, List<Pic> picList) {
		mContext = c;
		list = picList;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		View view = View.inflate(mContext, R.layout.relagrid, null);
		RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.relaGrid);
		ImageView image = (ImageView) rl.findViewById(R.id.chooseImage);
		TextView text = (TextView) rl.findViewById(R.id.chooseText);
		Pic pic = list.get(position);
		
		final String fileName=pic.getFilePath();
		image.setImageBitmap(pic.getBitmap());
		text.setText(pic.getFileName());
		view .setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent localIntent2 = new Intent();
				localIntent2.setClass(mContext, ImageViewAcity.class);
				localIntent2.putExtra("ImagePath",fileName);
				mContext.startActivity(localIntent2);
			}
		});
		return rl;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

}